/* 
 * File:   im-draw.h
 * Author: gustavo
 *
 * Created on May 28, 2011, 1:57 PM
 */

#ifndef DRAW_H
#define	DRAW_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <util/types.h>
#include <util/mem.h>

#include "../../imp_types.h"
#include "../image.h"

#include "fonts/font.h"
#include "color.h"

	typedef struct _imp_draw ImpDraw;

	struct _imp_draw {
		unsigned char * data;
		int width;
		int height;

		boolean rgb;

		ImpImage * img;
		Color fg;
		Color bg;
		float alpha;
		
		Font font;
	};

	//ImpDraw * imp_draw_new(ImpImage * Img);
	//void imp_draw_destroy(ImpDraw * draw);
	//#define imp_draw_delete( draw ) { imp_draw_destroy(draw); mem_free(draw); draw = NULL; }

	ImpDraw imp_draw_create(ImpImage * Img);
	void imp_draw_set_fg(ImpDraw * draw, Color color);
	void imp_draw_set_bg(ImpDraw * draw, Color color);


	void imp_draw_pixel(ImpDraw * draw, int x, int y);
	void imp_draw_segment(ImpDraw * draw, int x0, int y0, int x1, int y1);
	void imp_draw_rectangle(ImpDraw * draw, int x0, int y0, int x1, int y1);
	void imp_draw_rectangle_fill(ImpDraw * draw, int x0, int y0, int x1, int y1);
	void imp_draw_square(ImpDraw * draw, int x, int y, int ray);
	void imp_draw_square_fill(ImpDraw * draw, int x, int y, int ray);
	void imp_draw_cross(ImpDraw * draw, int x, int y, int ray);
	// =========================================================================
	void imp_draw_circle(ImpDraw * draw, int xm, int ym, int ray);

	// =========================================================================
	void imp_draw_text(ImpDraw * draw, int x, int y, int fillbg, char * template, ...);
	
	// =========================================================================
#include "../../geometry/geometry.h"

	void imp_draw_geom_point(ImpDraw * draw, ImpPoint * p);
	void imp_draw_geom_segment(ImpDraw * draw, ImpSegment * s);
	//void imp_draw_geom_triangle(ImpDraw * draw, ImpTriangle * t);
	void imp_draw_geom_triangle(ImpDraw * draw, ImpTriangle * t, boolean print_center);
	void imp_draw_list_of_geom_vertices(ImpDraw * draw, List * vertices);
	void imp_draw_list_of_geom_edges(ImpDraw * draw, List * edges);
	void imp_draw_list_of_geom_triangles(ImpDraw * draw, List * triangles, boolean print_center);



	// =========================================================================
	// =========================================================================
	// =========================================================================
	void imp_imdraw_set_color(Color cor);
	inline void imp_imdraw_put_pixel(ImpImage * img, int x, int y);
	void imp_imdraw_line(ImpImage * img, int x0, int y0, int x1, int y1);
	void imp_imdraw_rect(ImpImage * img, int x0, int y0, int x1, int y1);
	void imp_imdraw_cross(ImpImage * img, int x, int y, int ray);
	void imp_imdraw_circle(ImpImage * img, int xm, int ym, int ray);
	void imp_imdraw_ellipse(ImpImage * img, int xc, int yc, int a, int b, real deg);
	void imp_imdraw_print_text(ImpImage * img, int x, int y, int fillbg, char * template, ...);

	void imp_imdraw_poly(ImpImage * img, Ref2 * p, int n);
	void imp_imdraw_poly_fill(ImpImage * img, Ref2 * p, int n);

#ifdef	__cplusplus
}
#endif

#endif	/* DRAW_H */

